
function network(){
    this.chat;
    this.url = "virtualworl.com";
    this.port = "13001";




}

network.prototype.init = function(){
    var WebSocket = window.WebSocket || window.MozWebSocket;
    this.chat.ws = new WebSocket("ws://"+chat.host+":"+chat.port);

    //Connection state
    this.chat.ws.onopen = function(e) {
        chat.onChromeError=false
        document.getElementById('intro').style.display="block";
        document.getElementById('ws_icon').setAttribute('class',"connected");
        document.getElementById('ws_sentence').innerHTML = "Vous êtes connecté au serveur";
        setTimeout(main.gameNetwork.chat._get_pub_ID, 50);
    };
    this.chat.ws.onclose = function(e) {
        chat._quit_chat(e.data);
    };
    this.chat.ws.onerror = function(e) {
        document.getElementById('error').style.display="block";
        document.getElementById('ws_icon').setAttribute('class',"not_connected");
        document.getElementById('ws_sentence').innerHTML = "Connection impossible";
    };

    //Message
    this.chat.ws.onmessage = function(e) {
        chat._receive_msg(e.data);
    };

    //Chrome dont detect error where connexion refused
    setTimeout(main.gameNetwork.chat._chrome_error_handlers,1500);
}